#include "common.hpp"

int main()
{
    // cout << "I am server" << endl;
    Fifo fifo(PATH);
    // sleep(10);
    int rfd = open(PATH, O_RDONLY);
    if (rfd < 0)
    {
        cout << "open filed, errno: " << errno << ", error_string: " << strerror(errno) << endl;
        return 1;
    }
    char rbuff[1024];
    while(true)
    {
        ssize_t n = read(rfd, rbuff, sizeof(rbuff) - 1);
        if(n > 0)
        {
            rbuff[n] = '\0';
            cout << "client say :" << rbuff << endl;
        }
        else if(n == 0)
        {
            cout << "client done, me too!!!" << endl;
            break;
        }
        else
        {
            break;
        }

    }

    return 0;
}